package com.gg.admin.user.contorller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.admin.user.service.AdminUserService;
import com.gg.beanhelper.BeanHelper;
import com.gg.entity.User;

import helpers.baseservlet.BaseServlet;


@WebServlet("/admin/AdminChangeUserServlet")
public class AdminChangeUserServlet extends  BaseServlet {
	@Autowired
	private   AdminUserService   adminUserService;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		User   user   =   BeanHelper.getBean(request.getParameterMap(), User.class);
		User   thisuser   =  (User) request.getSession().getAttribute("thisuser");
		if(user.equals(thisuser)) {
			response.sendRedirect("/fruits/BSindex1.jsp");
			return  ;
		}
		adminUserService.changeUserByUid(user);
		
		request.getSession().setAttribute("users", adminUserService.ShowAllUsers());
		response.sendRedirect("/fruits/BSindex1.jsp");
		
		
		
	}

}
